//
// Created by Administrator on 2021/8/6.
//

#ifndef OPENGLLEARN_SHADERPROGRAM_H
#define OPENGLLEARN_SHADERPROGRAM_H

#include <utility>

#include "Common.h"

#include "glad/glad.h"

#include "string"

struct ShaderInfo
{
public:
    ShaderInfo(std::string v,
               std::string f,
               std::string tc = std::string(),
               std::string te = std::string(),
               std::string ge = std::string())
        : vertPath(std::move(v)),
        fragPath(std::move(f)),
        tcsPath(std::move(tc)),
        tesPath(std::move(te)),
        geoPath(std::move(ge)) {}

    std::string vertPath;
    std::string fragPath;
    std::string tcsPath;
    std::string tesPath;
    std::string geoPath;
};

class ShaderProgram
{
public:
    ShaderProgram();
    explicit ShaderProgram(const ShaderInfo& info);
    ~ShaderProgram();

    void Use() const;
    void SetFloat(const std::string& name, GLfloat value) const;
    void SetVector3(const std::string& name, const GLfloat* value) const;
    void SetVector4(const std::string& name, const GLfloat* value) const;
    void SetMatrix4(const std::string& name, const GLfloat* value) const;

    GLuint id() const;

private:
    static void CheckCompile(GLuint target);

    GLuint id_{};
};

#endif //OPENGLLEARN_SHADERPROGRAM_H
